package com.jilijili.interceptor;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class InterceptorConfig implements WebMvcConfigurer {

    @Bean
    public PassportInterceptor passportInterceptor() {
        return new PassportInterceptor();
    }

    @Bean
    public UsersInterceptor usersInterceptor() {
        return new UsersInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(passportInterceptor())
                .addPathPatterns("/api/passport/getSMSCode"); // 获取验证码前拦截

        registry.addInterceptor(usersInterceptor())
                .addPathPatterns("/api/userInfo/modifyUserInfo") // 修改用户信息前拦截
                .addPathPatterns("/api/fileUpload/modifyImage"); // 修改图片前拦截
    }
}
